home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 5_5.lha / 5_5 / main.c < prev    next >
Text File  |  1993-08-08  |  560b  |  37 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. har *strs[] =
  6.  
  7.    "",
  8.    "1 ",
  9.    "2*3 ",
  10.    "2-3 ",
  11.    "5/2",
  12.    "123/4+123*4-3",
  13.    0
  14. ;
  15.  
  16. oid lookat(char *s)
  17.  
  18.    cout << "x = '" << s << "'\n";
  19.    expr x(s);
  20.    cout << "x = "; x.print(); cout << "\n";
  21.    cout << "x = " << x.eval() << "\n";
  22.    cout << "\n";
  23.  
  24.  
  25. ain(int argc, char **argv)
  26.  
  27.    if (argc > 1)
  28. while (*++argv)
  29.     lookat(*argv);
  30.  
  31.    else
  32. for (int i = 0; strs[i]; i++)
  33.     lookat(strs[i]);
  34.  
  35.    return 0;
  36.  
  37.